using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace QuickLaunch
{
    class FormManagement
    {
        private List<Form> forms = new List<Form>();

        private Timer timer = new Timer();

        public FormManagement()
        {
            timer.Interval = 100;
            timer.Tick += new EventHandler(timer_Tick);
        }

        void timer_Tick(object sender, EventArgs e)
        {
            // make all the form invisible
            foreach (Form form in forms)
            {
                if (form != null && form.Visible)
                    form.Visible = false;
            }
            timer.Stop();
        }

        public void AddForm(Form form)
        {
            form.Activated += new EventHandler(form_Activated);
            form.Deactivate += new EventHandler(form_Deactivate);
            forms.Add(form);
        }

        void form_Activated(object sender, EventArgs e)
        {
            timer.Stop();
        }

        void form_Deactivate(object sender, EventArgs e)
        {
            timer.Start();
        }
    }
}
